<template>
  <div class="person">
    <h1>我是Person组件</h1>
    普通输入框：<input type="text" :value="str" @input="handle1"> <br>
    单选按钮（radio）：
      男<input type="radio" name="sex" :checked="gender==='男'" @click="handle2('男')"> 
      女<input type="radio" name="sex" :checked="gender==='女'" @click="handle2('女')"> <br>
    多选按钮(checkbox)：
      <input type="checkbox" :checked="isAgree" @click="handle3">
  </div>
</template>

<script>
  export default {
    name:'Person',
    props:['str','updateStr','gender','updateGender','isAgree','updateIsAgress'],
    methods: {
      handle1(event){
        // console.log(event.target.value)
        this.updateStr(event.target.value)
      },
      handle2(value){
        this.updateGender(value)
      },
      handle3(event){
        this.updateIsAgress(event.target.checked)
      }
    },
  }
</script>

<style scoped>
  .person {
    background-color: skyblue;
    padding: 20px;
  }
</style>